package chp05;

import java.util.Scanner;

public class Test9 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        //假设账号是admin 密码是1234
        //如果用户名和密码符合，输出登录成功
        //给三次登录机会，如果三次都不符合，结束登录流程
        int num = 1;
        //是否登录成功
        boolean flag = false;
        while (num <= 3) {
            System.out.print("请输入用户名:");
            String username = input.next();
            System.out.print("请输入密码:");
            String password = input.next();
            if(username.equals("admin") && password.equals("1234")){
                flag = true;
                break;
            }else{
                System.out.println("账号或密码错误");
            }
            num++;
        }

        if(flag == true){
            System.out.println("登录成功");
        }else{
            System.out.println("三次登录失败，账号锁定");
        }
    }
}
